//
//  UIImage+Extension.swift
//  weiBo项目准备
//
//  Created by 鲜世杰 on 16/5/20.
//  Copyright © 2016年 鲜世杰. All rights reserved.
//

import UIKit


extension UIImage {


    func scaleImageWithWidth(scaleWidth : CGFloat) -> UIImage {
        let scaleHeight = scaleWidth / self.size.width * self.size.height

        let size = CGSize(width: scaleWidth, height: scaleHeight)
        
        UIGraphicsBeginImageContext(size)
        self.drawInRect(CGRect(origin: CGPointZero, size: size))
        
        let scaleImage = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return scaleImage
        
    }

}